<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/4/20/020
 * Time: 9:03
 */

namespace app\index\controller;


use app\Lib\Model\Login\DoLogin;
use app\Lib\Model\Login\WeiXiGetOpenId;
use think\Controller;
use think\Url;

class Base extends Controller
{
    protected $login_uid;
    protected $userInfo;
    public function _initialize()
    {

        $login =(new DoLogin());
        $login->setLoginKey('weiXin_web_log_key');
        $module = $this->request->module();//模块名

        $controller = $this->request->controller();//控制器名

        $action = $this->request->action();//方法名
        cookie('firstUrl',$module.DS.$controller.DS.$action);
        //验证登录 获取openid
        if(!$login->isLogin()){
            (new WeiXiGetOpenId())->getCode();
//            echo 1;
        }
        //判断是否属于多重登录
//        if(!$login->validateLogin()){
//            //清除这台设备的登录标识
//            $login->webOutLogin();
//        }

        $this->login_uid = session('login_uid');
        $this->login_uid = empty($this->login_uid)?cookie(md5('userInfo')):$this->login_uid;
        $this->userInfo = session('userInfo');
        $this->userInfo = empty($this->userInfo)?cookie(md5('userInfoBase')):$this->userInfo;
        $userInfo = $this->userInfo;
        $this->assign('userInfo',$userInfo);
    }


}